<%--
  Created by IntelliJ IDEA.
  User: sgx
  Date: 2021/4/6
  Time: 11:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript">
        $(function () {
            var user = {                 // 0.创建1个User对象。
                id : 1,
                name : "五五开",
                adress : {
                    number : 266000,
                    name : "青岛"
                }
            };
            $.ajax({                    // 创建Ajax
                url:"data/json",        // 1.访问Servlet程序
                data:JSON.stringify(user),// 2.发送数据：把user转成JSON
                type:"PSOT",              // 3.POST方式 发送
                contentType:"application/json;charset=UTF-8", // 4.设置数据编码UTF-8
                dataType:"JSON",        // 5.返回结果集类型：JSON类型
                success:function (data) { // 6.接收成功
                    alert(data.id+", "+data.name + ", address: "+data.adress.number+", "+data.adress.name);
                }
            })
        });
    </script>
</head>
<body>

</body>
</html>
